package es.cea.listeners;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import es.cea.web.Stat;

/**
 * Application Lifecycle Listener implementation class EstadisticasCicloVidaSesion
 *
 */
@WebListener
public class EstadisticasCicloVidaSesion implements HttpSessionListener {

    /**
     * Default constructor. 
     */
//	List <Stat> estadisticasSesion;
	
    public EstadisticasCicloVidaSesion() {
        // TODO Auto-generated constructor stub
//    	estadisticasSesion = new ArrayList<Stat>();
    }

	/**
     * @see HttpSessionListener#sessionCreated(HttpSessionEvent)
     */
    public void sessionCreated(HttpSessionEvent arg0) {
        // TODO Auto-generated method stub
    	List <Stat> estadisticasSesion = estadisticasSesion = new ArrayList<Stat>();
    	HttpSession sesion = arg0.getSession();
    	sesion.setAttribute("estadisticas", estadisticasSesion);
    }

	/**
     * @see HttpSessionListener#sessionDestroyed(HttpSessionEvent)
     */
    public void sessionDestroyed(HttpSessionEvent arg0) {
        // TODO Auto-generated method stub
    	System.out.println("Se ha cerrado la sesion");
    }
	
}
